package com.spzx.product.controller;

import com.spzx.common.core.domain.R;
import com.spzx.common.security.annotation.InnerAuth;
import com.spzx.product.domain.ProductSku;
import com.spzx.product.service.IProductSkuService;
import com.spzx.product.api.domain.ProductSkuVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.spzx.common.core.web.controller.BaseController;

/**
 * <p>
 * 商品sku 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2025-03-12
 */
@RestController
@RequestMapping("/productSku")
public class ProductSkuController extends BaseController {

    @Autowired
    private IProductSkuService productSkuService;

    @InnerAuth //微服务内部接口
    @Operation(summary = "获取商品SKU详情")
    @GetMapping("/getProductSku/{skuId}")
    public R<ProductSkuVo> getProductSku(
            @Parameter(description = "skuId")
            @PathVariable("skuId") Long skuId) {

        ProductSkuVo productSkuVo = new ProductSkuVo();
        ProductSku productSku = productSkuService.getById(skuId);
        BeanUtils.copyProperties(productSku, productSkuVo);

        return R.ok(productSkuVo);
    }

}
